﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.mediator;
using SharpSqlAnalyzer.pp.mediator.type;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.pp.utils;

namespace SharpSqlAnalyzer.pp.processor.type.alter
{
	// Token: 0x02000257 RID: 599
	public class AlterTableOptionItemAlignProcessor : AbstractProcessor
	{
		// Token: 0x06001342 RID: 4930 RVA: 0x0031E680 File Offset: 0x0031C880
		public virtual void process(TAlterTableOptionList options)
		{
			bool parameter = this.getParameter<bool>(typeof(bool));
			if (options == null || options.size() == 0)
			{
				return;
			}
			int num = 0;
			for (int i = 0; i < options.size(); i++)
			{
				int length = options.getAlterTableOption(i).ToString().Length;
				if (length > num)
				{
					num = length;
				}
			}
			for (int j = 0; j < options.size(); j++)
			{
				TAlterTableOption alterTableOption = options.getAlterTableOption(j);
				int num2 = 0;
				KeywordAlignMediator mediator = MediatorFactory.getMediator<KeywordAlignMediator>(typeof(KeywordAlignMediator), this.Option.sessionId);
				if (mediator.CurLevelIndentLen > num2)
				{
					num2 = mediator.CurLevelIndentLen;
				}
				mediator.addIndentLevelItem(alterTableOption.startToken, num2);
				if (parameter)
				{
					SourceTokenOperator.addBefore(this.Option, alterTableOption.startToken, SourceTokenOperator.createReturnSourceToken());
					SourceTokenOperator.addBefore(this.Option, alterTableOption.startToken, SourceTokenOperator.createWhitespaceSourceToken(num2 + this.Option.indentLen));
				}
				else
				{
					SourceTokenOperator.addBefore(this.Option, alterTableOption.startToken, SourceTokenConstant.WHITESPACE);
				}
			}
		}
	}
}
